import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../logic.dart';

class IconList extends StatefulWidget {
  const IconList({Key? key}) : super(key: key);

  @override
  State<IconList> createState() => _IconListState();
}

class _IconListState extends State<IconList> {
  final _logic = Get.find<RecordTypeLogic>();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(title: Text("选择图标")),
        body: Container(
            // color: Colors.red,
            child: GridView.builder(
                gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                    crossAxisCount: 5),
                itemCount: _logic.state.allIcons.length,
                itemBuilder: (context, index) {
                  return InkWell(
                    key: ValueKey(index),
                    onTap: () {
                      Get.back(result: _logic.state.allIcons[index]);
                    },
                    child: Container(
                        padding: EdgeInsets.all(16),
                        child: Image.asset(_logic.state.allIcons[index])),
                  );
                })));
  }

  @override
  initState() {
    super.initState();
  }
}
